<template>
    <div class="container">
        <!--查询区域-->
        <div>
            <el-form :inline="true" :model="searchData" label-width="120px" class="demo-form-inline">
                <el-form-item label="AO编码:">
                    <el-input v-model="searchData.aoCode" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="工作包编码:">
                    <el-input v-model="searchData.packageCode" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="图号:">
                    <el-input v-model="searchData.itemCode" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="机型:">
                    <el-input v-model="searchData.productCode" class="el-form-input" size="mini" placeholder="10403"></el-input>
                </el-form-item>
                <el-form-item label="批次:">
                    <el-input v-model="searchData.batchNo" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="起始架次:">
                    <el-input v-model="searchData.startPlaneNo" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="是否分拣:">
                    <el-select ref="saomaInput" class="el-form-input" size="mini" v-model="searchData.isSort" placeholder="请选择">
                        <el-option v-for="item in isSortStatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="配套状态:">
                    <el-select ref="saomaInput" class="el-form-input" size="mini" v-model="searchData.state" placeholder="请选择">
                        <el-option v-for="item in stateStatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select> 
                </el-form-item>
                <el-form-item label="配送状态:">
                    <el-select ref="saomaInput" class="el-form-input" size="mini" v-model="searchData.deliveryState" placeholder="请选择">
                        <el-option v-for="item in deliveryStatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select> 
                </el-form-item>
                <!-- <el-form-item label="月计划开始时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.monthStartTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item> -->
                <!-- <el-form-item label="月计划结束时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.monthEndTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item> -->
                <el-form-item label="周计划开始时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.weekStartTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item>
                <el-form-item label="周计划结束时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.weekEndTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item>
                <el-form-item label="日计划开始时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.dailyStartTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item>
                <el-form-item label="日计划结束时间">
                    <el-date-picker size="mini" class="el-form-input" v-model="searchData.dailyEndTime" type="date" placeholder="选择日期" 
                    value-format="yyyy-MM-dd" ></el-date-picker>
                </el-form-item>
                <el-form-item label="是否下发日计划:">
                    <el-select ref="saomaInput" class="el-form-input" size="mini" v-model="searchData.isDownDaily" placeholder="请选择">
                        <el-option label="所有状态" value=""></el-option>
                        <el-option label="已下发" value="Y"></el-option>
                        <el-option label="未下发" value="N"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="是否下发周计划:">
                    <el-select ref="saomaInput" class="el-form-input" size="mini" v-model="searchData.isDownWeek" placeholder="请选择">
                        <el-option label="所有状态" value=""></el-option>
                        <el-option label="已下发" value="Y"></el-option>
                        <el-option label="未下发" value="N"></el-option>
                    </el-select>
                </el-form-item>
                 <el-form-item label="占位:">
                    <el-input v-model="searchData.station" class="el-form-input" size="mini" placeholder="请输入"></el-input>
                </el-form-item>

            </el-form>
            <div style="text-align: center;margin-bottom:3px">
                <el-button type="primary" size="mini" @click="smSpmSearch">查询</el-button>
                <el-button type="primary" size="mini" @click="doReset">重置</el-button>
            </div>
        </div>
        <!--列表展示区域-->
        <div class="em-spm-topTable">
            <el-table
                ref="receiveTable"
                size="mini"
                :data="resData"
                style="width: 100%"
                height="400"
                highlight-current-row
                @selection-change="handleSelectionChange"
                >
                <el-table-column type="selection" width="40"> </el-table-column>
                <el-table-column prop="addType" label="配套类型" width="70" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="itemName" label="物料名称" width="150" :show-overflow-tooltip="true" > </el-table-column>
                <el-table-column prop="itemCode" label="物料编码" width="150" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="qualityCode" label="质量编号/件号" width="150" :show-overflow-tooltip="true"> </el-table-column>
                <!-- <el-table-column prop="isPaper" label="是否带证" :show-overflow-tooltip="true"> </el-table-column> -->
                <el-table-column prop="toolCode" label="托盘号" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="workbinCode" label="箱子号" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="creationDate" label="创建时间" width="170" :show-overflow-tooltip="true"> </el-table-column>

                <el-table-column prop="startPlaneNo" label="架次" width="50" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="batchNo" label="批次" width="50" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="aoCode" label="AO编码" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="repartAss" label="装配图号" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="itemQty" label="需求数量" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="matchQty" label="配套数量" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="packageCount" label="分拣数量" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="returnQty" label="退库数量" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="secondQty" label="二次配套数量" width="100" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="barcode" label="条码" width="150" :show-overflow-tooltip="true"> </el-table-column>
                <!-- <el-table-column prop="isPaper" label="是否带证" width="80" :show-overflow-tooltip="true"> </el-table-column> -->
                <el-table-column prop="isSort" label="是否分拣" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="state" label="配套状态" :show-overflow-tooltip="true"> </el-table-column>
                
                <el-table-column prop="deliveryState" label="配送状态" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="deliveryTime" label="配送时间" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="deliveryEmpCode" label="配送人" :show-overflow-tooltip="true"> </el-table-column>

                <el-table-column prop="monthTime" label="月计划" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="weekTime" label="周计划" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="dailyTime" label="日计划" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="artChangeType" label="工艺更改类型" width="100" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="productCode" label="机型" width="80" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="packageCode" label="工作包编码" width="150" :show-overflow-tooltip="true"> </el-table-column>

                <el-table-column prop="itemType" label="物料类型" width="150" :show-overflow-tooltip="true" > </el-table-column>
                <el-table-column prop="mesCheckQualiticationId" label="合格证" width="170" :show-overflow-tooltip="true"> </el-table-column>
                <!-- <el-table-column prop="wmsDeliveryPlanId" label="交接单ID" width="170" :show-overflow-tooltip="true"> </el-table-column> -->
                <el-table-column prop="wmsItemInventoryId" label="台账ID" width="170" :show-overflow-tooltip="true"> </el-table-column>
                
            </el-table>
            <!-- 分页 -->
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="pageNumber"
                :page-sizes="[10,20,50,100]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalCount">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import { smSpmLastTableData } from "@/utils/api.js";
import { smSpmTopTableData } from "@/utils/api.js"
export default {
    name:"SpmTopTable",
    data(){
        return{
            searchData:{//查询参数
                "station":"",
                "productCode":"",
                "aoCode":"",
                "packageCode":"",
                "itemCode":"",
                "batchNo":"",
                "startPlaneNo":"",
                "isSort":"",
                "state":"",
                "deliveryState":"",
                "monthStartTime":"",
                "monthEndTime":"",
                "weekStartTime":"",
                "weekEndTime":"",
                "dailyStartTime":"",
                "dailyEndTime":"",
                "isDownDaily":"",
                "isDownWeek":"",
            },
             // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 确认列表高亮参数
            stableIndex: 0,
            // 接收Top传来的数据--用于查表
            topLastInfo:'',
            isSortStatus: [
                {
                value: "Y",
                label: "已分拣",
                },
                {
                value: "N",
                label: "未分拣",
                },
                {
                value: "",
                label: "所有",
                },
            ],
            deliveryStatus:[
                {
                value: "02",
                label: "已配送",
                },
                {
                value: "00",
                label: "未配送",
                },
                {
                value: "04",
                label: "已移交",
                },
                {
                value: "06",
                label: "已接收",
                },
                {
                value: "",
                label: "所有",
                },
            ],
            stateStatus: [
                {
                value: "02",
                label: "已配套",
                },
                {
                value: "00",
                label: "未配套",
                },
                {
                value: "04",
                label: "部分配套",
                },
                {
                value: "01",
                label: "无库存",
                },
                {
                value: "",
                label: "所有",
                },
            ],
        }
    },
    methods:{
        // 勾选表格函数
        handleSelectionChange(val) {  
            
        },
        //重置
        doReset(){
            Object.assign(this.searchData,this.$options.data().searchData);
        },
        // 分页---每页数据条数---传给TopSearch
        handleSizeChange(val){
            this.pageSize = val;
            smSpmLastTableData({
                searchParams:{
                    
                    station:this.searchData.station,
                    productCode:this.searchData.productCode,
                    batchNo:this.searchData.batchNo,
                    startPlaneNo:this.searchData.startPlaneNo,
                    monthStartTime:this.searchData.monthStartTime,
                    monthEndTime:this.searchData.monthEndTime,
                    weekStartTime:this.searchData.weekStartTime,
                    weekEndTime:this.searchData.weekEndTime,
                    dailyStartTime:this.searchData.dailyStartTime,
                    dailyEndTime:this.searchData.dailyEndTime,
                    aoCode:this.searchData.aoCode,
                    packageCode:this.searchData.packageCode,
                    isSort:this.searchData.isSort,
                    state:this.searchData.state,
                    itemCode:this.searchData.itemCode,
                    deliveryState:this.searchData.deliveryState,
                    isDownDaily:this.searchData.isDownDaily,
                    isDownWeek:this.searchData.isDownWeek
                },
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('分拣预配套Last表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
        // 分页---页数---传给TopSearch
        handleCurrentChange(val) {
            this.pageNumber = val;
            smSpmLastTableData({
                searchParams:{
                    station:this.searchData.station,
                    productCode:this.searchData.productCode,
                    batchNo:this.searchData.batchNo,
                    startPlaneNo:this.searchData.startPlaneNo,
                    monthStartTime:this.searchData.monthStartTime,
                    monthEndTime:this.searchData.monthEndTime,
                    weekStartTime:this.searchData.weekStartTime,
                    weekEndTime:this.searchData.weekEndTime,
                    dailyStartTime:this.searchData.dailyStartTime,
                    dailyEndTime:this.searchData.dailyEndTime,
                    aoCode:this.searchData.aoCode,
                    packageCode:this.searchData.packageCode,
                    isSort:this.searchData.isSort,
                    state:this.searchData.state,
                    itemCode:this.searchData.itemCode,
                    deliveryState:this.searchData.deliveryState,
                    isDownDaily:this.searchData.isDownDaily,
                    isDownWeek:this.searchData.isDownWeek
                },
                pageParameter: {
                    rows: this.pageSize,
                    page: this.pageNumber
                },
                }).then((res) => {
                    console.log('分拣预配套Last表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
        smSpmSearch(){
            smSpmTopTableData({
                searchParams:{
                    station:this.searchData.station,
                    productCode:this.searchData.productCode,
                    batchNo:this.searchData.batchNo,
                    startPlaneNo:this.searchData.startPlaneNo,
                    monthStartTime:this.searchData.monthStartTime,
                    monthEndTime:this.searchData.monthEndTime,
                    weekStartTime:this.searchData.weekStartTime,
                    weekEndTime:this.searchData.weekEndTime,
                    dailyStartTime:this.searchData.dailyStartTime,
                    dailyEndTime:this.searchData.dailyEndTime,
                    aoCode:this.searchData.aoCode,
                    packageCode:this.searchData.packageCode,
                    isSort:this.searchData.isSort,
                    state:this.searchData.state,
                    itemCode:this.searchData.itemCode,
                    deliveryState:this.searchData.deliveryState,
                    isDownDaily:this.searchData.isDownDaily,
                    isDownWeek:this.searchData.isDownWeek
                },
                pageParameter:{
                    rows:this.pageSize,
                    page:this.pageNumber
                }
            }).then((res)=>{
                if(res.data.retCode == 200){
                  //  this.resData = res.xxx
                    this.resData = res.data.responseBody.result
                    this.totalCount = res.data.responseBody.pageParameter.totalCount
                }
            })
        }
    },
    mounted() { 
        smSpmLastTableData({
            searchParams:{
                // msTaskAoId:this.topLastInfo
            },
            pageParameter: {
                rows: this.pageSize,
                page: this.pageNumber
            },
        }).then((res) => {
            console.log('分拣预配套Last表',res)
            this.resData = res.data.responseBody.result;
            this.totalCount = res.data.responseBody.pageParameter.totalCount;
        });
        // TopSearch 查询的数据
      /*  this.$bus.$on('smSpmTopSearchData',(e)=>{
            this.resData = e.data.responseBody.result
            this.totalCount = e.data.responseBody.pageParameter.totalCount
        })*/

  }
}
</script>
<style scoped>
.em-spm-topTable {
    text-align: center;
}
.el-form-item{
    margin-bottom:0px !important;
}
.el-form-input{
    width:120px
}
</style>